package function;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.feiniaoji.R;

import java.util.List;

/**
 * Created by 林立鹏 on 2017/7/12.
 */

public class stragetyAdapter extends ArrayAdapter<strategy> {
    private int resourceId;
    public stragetyAdapter(Context context, int textViewResourceId,
                           List<strategy> objects){
        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        strategy strategy = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        ImageView strategyImage = (ImageView)view.findViewById(R.id.stragety_image);
        TextView strategyNmae = (TextView)view.findViewById(R.id.stragety_name);
        TextView strategyAuthor = (TextView) view.findViewById(R.id.stragety_author);
        ImageLoaderUtils.displayImage(strategy.getPicUrl(),strategyImage);
        strategyNmae.setText(strategy.getStraName());
        strategyAuthor.setText(strategy.getAuther());
        return view;
    }
}
